#include "process.h"
#define TAREGT_SIZE 1024*1024
#define DSIZE 1024*10

void download(callback cb)
{   
    int testcnt = 100;
    int target = TAREGT_SIZE;
    int sum = 0;
    while(sum<=target)
    {
        usleep(STIME);
        sum += DSIZE;
        int rate = (sum*100/target);
        cb(rate);//回调函数
        if(rate>=50&&testcnt)
        {
            sum = target/2;
            testcnt--;
        }
    }
    printf("\n");
}

int main()
{
    //process(); 
    //download(process2);
    download(process3);
    return 0;
}
